﻿/*
 *  Author: Louis A. Leskoviansky
 *  Company: Artemis Solutions Group (http://www.artemis-solutions.com)
 */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;

namespace AjaxControlFramework
{
    public class InlineScriptReference : ScriptReference
    {
        //------// Properties \\--------------------------------------------\\
        private string _sourceCode = String.Empty;
        public virtual string SourceCode
        {
            get { return _sourceCode; }
            set
            {
                if (value == null)
                {
                    _sourceCode = String.Empty;
                }
                else
                {
                    _sourceCode = value;
                }
            }
        }
        //------\\ Properties //--------------------------------------------//



        //------// Constructors \\------------------------------------------\\
        public InlineScriptReference(string name, string sourceCode)
            : base(name)
        {
            SourceCode = sourceCode;
        }
        //------\\ Constructors //------------------------------------------//



        //------// Methods \\-----------------------------------------------\\
        public override string GenerateScriptBlock()
        {
            StringBuilder scriptBlock = new StringBuilder(50 + SourceCode.Length);
            scriptBlock.Append("<script type=\"text/javascript\">").Append(SourceCode).Append("</script>");

            return scriptBlock.ToString();
        }
        //------\\ Methods //-----------------------------------------------//
    }
}